<template>
  <div>
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>补盲扩项目详情
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="nav">项目详情</div>

      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick" class="tabs">
        <el-tab-pane label="项目信息" name="first">
          <div class="tables"  v-if="ms_roleName != 'AreaManager' && ms_roleName != 'WorkTeamManager'">
            <table cellpadding="0" cellspacing="0" border="1">
              <tr>
                <td>工单委托日期</td>
                <td>{{baseInfo.entrustDate|dateFilter}}</td>
                <td>扩容类型</td>
                <td>{{baseInfo.bmkAddType}}</td>
              </tr>
              <tr>
                <td>所属单位</td>
                <td>{{baseInfo.bmkOrg}}</td>
                <td>所属工队</td>
                <td>{{baseInfo.bmkWorkteam}}</td>
              </tr>
              <tr>
                <td>修补扩类型</td>
                <td>{{baseInfo.bmkFixType}}</td>
                <td>所属项目部</td>
                <td>{{baseInfo.belongOrg}}</td>
              </tr>
              <tr>
                <td>片区</td>
                <td>{{baseInfo.bmkArea}}</td>
                <td>镇区</td>
                <td>{{baseInfo.bmkTown}}</td>
              </tr>
              <tr>
                <td>五级站点</td>
                <td>{{baseInfo.bmkStation}}</td>
                <td>需求内容</td>
                <td>{{baseInfo.bmkNeedContent}}</td>
              </tr>
              <tr>
                <td>关联安装工单号</td>
                <td>{{baseInfo.bmkRelevanceNo}}</td>
                <td>是否超时</td>
                <td>{{baseInfo.bmkIsovertime == '1'?'是':'否'}}</td>
              </tr>
              <tr>
                <td>所属网格</td>
                <td>{{baseInfo.bmkGrid}}</td>
                <td>要求完工日期</td>
                <td>{{baseInfo.planEdate|timeFilter}}</td>
              </tr>
              <tr>
                <td>实际完工日期</td>
                <td>{{baseInfo.realEdate|timeFilter}}</td>
                <td></td>
                <td></td>
              </tr>
            </table>
          </div>
          <div class="tables"  v-if="ms_roleName == 'AreaManager' || ms_roleName == 'WorkTeamManager'">
            <table cellpadding="0" cellspacing="0" border="1">
              <tr>
                <td>工单委托日期</td>
                <td>{{baseInfo.entrustDate|dateFilter}}</td>
                <td>所属单位</td>
                <td>{{baseInfo.bmkOrg}}</td>
              </tr>
              <tr>
                <td>片区</td>
                <td>{{baseInfo.bmkArea}}</td>
                <td>镇区</td>
                <td>{{baseInfo.bmkTown}}</td>
              </tr>
              <tr>
                <td>五级站点</td>
                <td>{{baseInfo.bmkStation}}</td>
                <td>需求内容</td>
                <td>{{baseInfo.bmkNeedContent}}</td>
              </tr>

              <tr>
                <td>工单号</td>
                <td>{{baseInfo.bmkRelevanceNo}}</td>
                <td>所属网格</td>
                <td>{{baseInfo.bmkGrid}}</td>
              </tr>
              <tr>
                <td>施工单位</td>
                <td>{{baseInfo.bmkWorkteam}}</td>
                <td>施工人员</td>
                <td>{{baseInfo.workerName}}</td>
              </tr>
              <tr>
                <td>联系电话</td>
                <td>{{baseInfo.workerPhone}}</td>
                <td>修补扩类型</td>
                <td>{{baseInfo.bmkFixType}}</td>
              </tr>
              <tr>
                <td>要求完工日期</td>
                <td>{{baseInfo.planEdate|timeFilter}}</td>
                <td>实际完工日期</td>
                <td>{{baseInfo.realEdate|timeFilter}}</td>
              </tr>
            </table>
          </div>
        </el-tab-pane>
        <el-tab-pane label="工程量管理" name="second">
          <div class="expansion-amap">
            <!-- 地图展示 Start -->
            <expansion-amap
              style="margin-bottom:20px;"
              :readOnlyAmapData="readOnlyAmapData"
              v-loading="amapReadOnlyLoading"
              element-loading-text="地图加载中..."
              element-loading-spinner="el-icon-loading"
              v-if="!amapReadOnlyLoading"
            ></expansion-amap>
            <!-- 地图展示 End -->
          </div>
          <div class="gcl">
            <div class="title">工程量</div>
            <el-table :data="workLoad" tooltip-effect="dark" style border>
              <el-table-column label="序号" align="center" width="55" type="index"></el-table-column>
              <el-table-column label="工作项目名称" align="center" prop="optionName"></el-table-column>
              <el-table-column label="单位" align="center" width="80" prop="unit"></el-table-column>
              <el-table-column label="费用" align="center" width="90" prop="fee"></el-table-column>
              <el-table-column label="工作量" align="center" width="100" prop="workLoad"></el-table-column>
              <el-table-column label="人天单价" align="center" width="100" prop="labourCost"></el-table-column>
              <el-table-column label="甲方结算单项费用" align="center" width="130" prop="partBCost"></el-table-column>
              <el-table-column label="施工队结算单价" align="center" width="125" prop="teamSettlement"></el-table-column>
              <el-table-column label="施工队费用" align="center" width="125" prop="teamFinalCost"></el-table-column>
            </el-table>
          </div>
          <div class="gcl_footer">
            <div class="gcl_footer_top">
              <span>甲方结算合计：</span>
              <span>{{money.budget}} 元</span>
            </div>
            <div class="gcl_footer_bottom">
              <span>施工队费用合计：</span>
              <span>{{money.finalbudget}} 元</span>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="材料管理" name="third">
          <div class="material-manage">
            <div class="budget-material">
              <div class="search-header">
                <div class="left-title">
                  <p class="left-text">
                    <span class="iconfont">&#xe607;</span>
                    预算材料
                  </p>
                  <div class="right"></div>
                </div>
              </div>
              <div class="table">
                <el-table
                  ref="multipleTable"
                  :data="materialsList"
                  tooltip-effect="dark"
                  style="width: 1100px;margin:0 auto"
                  border
                >
                  <el-table-column label="序号" align="center" width="60" type="index"></el-table-column>
                  <el-table-column label="材料名称" align="center"  prop="matName"></el-table-column>
                  <el-table-column label="规格型号" align="center" width="200" prop="matModel"></el-table-column>
                  <el-table-column label="单位" align="center" width="120" prop="matUnit"></el-table-column>
                  <el-table-column label="上报工程量" align="center" width="120" prop="workLoad"></el-table-column>
                  <el-table-column label="供方" align="center" width="120" prop="matSupplier"></el-table-column>
                </el-table>
              </div>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import expansionAmap from "./expansionAmap/expansionAmap";
export default {
  data() {
    return {
      ms_roleName:localStorage.getItem('roleName'),
      baseUrl: img_url,
      activeName: "first",
      // 工程量管理-子表格title
      subTitle: "线路队",
      // 工程量管理 预结算总计
      money:{
        finalbudget: "",
        budget: ""
      },
      //项目信息
      baseInfo: {},
      // 材料管理 - 表格
      materialsList: [],
      // 工程量
      workLoad:[],
      // amap
      readOnlyAmapData: {}, // 施工队地图只读数据
      amapLoading: true, // 控制地图loading
      amapReadOnlyLoading: true
    };
  },
  created() {
    this.activeName = this.$route.params.tabs || 'first';
    this.proInfoInit();
  },
  mounted() {
    // this.getReadOnlyAmapData()
  },
  methods: {
    //tab切换
    handleClick(tab, event) {
      switch (this.activeName) {
        case "first":
          this.proInfoInit();
          break;
        case "second":
          this.quantitiesInfoInit();
          break;
        case "third":
          this.materDataInit();
          break;
      }
    },
    // 项目信息
    proInfoInit() {
      let that = this,
        suCb = res => {
          console.log("项目信息", res);
          that.baseInfo = that.deepClone(res.data.data)
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proProject/getBmkProDetails",
          methods: "post",
          data: { proId: that.$route.params.proId },
          success: suCb,
          error: erCb
        };
      that.$https(req);
    },
    // 工程量信息
    quantitiesInfoInit(type) {
      let that = this,
        suCb = res => {
          console.log("工程量信息：", res);
          that.workLoad = res.data.data.workLoads||[];
          that.money = res.data.data.settle||{};
          // 地图打点集合 res.data.data.MapPoints
          // 接口返回地图数据
          let data = res.data.data.MapPoints
          let pro_id = data.proId;
          let pro_lnglat = [data.lng, data.lat];
          let points = data.mapPointList;

          this.readOnlyAmapData.pro_id = pro_id;
          this.readOnlyAmapData.pro_lnglat = pro_lnglat;
          this.readOnlyAmapData.points = points;
          this.amapReadOnlyLoading = false;
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proProject/queryBMKWorkLoad",
          methods: "post",
          // data: {proId:'testdetail'},
          data: { proId: that.$route.params.proId},
          success: suCb,
          error: erCb
        };
      console.log("工程量信息参数：", req.data);
      that.$https(req);

      // 模拟数据测试
      // mock的模拟数据
      // this.$axios.get("/mock/expansionAmapTestData.json").then(res => {
      //   // console.log(res,"axios.get")
      //   suCb(res);
      // });
    },
    // 材料管理 - 信息查询
    materDataInit() {
      let that = this,
        suCb = res => {
          console.log("材料信息：", res);
          that.materialsList = res.data.proMaterials;
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proProject/queryBMKMaterial",
          methods: "post",
          data: { proId: that.$route.params.proId },
          success: suCb,
          error: erCb
        };
      that.$https(req);
    },
    /**
     * 获取施工队上传数据后绘图的方法(因接口和 /api/web/proProject/queryBMKWorkLoad 公用而废弃)
     */
    getReadOnlyAmapData() {
      let succ = res => {
        res = res.data;
        if (res.flag == 1) {
          res = res.res;
          // console.log("res", res)
          let points = res.mapPointList;
          let pro_id = res.proId;
          let pro_lnglat = [res.lng, res.lat];
          this.readOnlyAmapData.pro_id = pro_id;
          this.readOnlyAmapData.pro_lnglat = pro_lnglat;
          this.readOnlyAmapData.points = points;
          this.amapReadOnlyLoading = false;
        }
      };
      let err = res => {
        that.$erMsg('网络错误')
      };
      let params = {
        proId: this.$route.params.proId
				
      };
      let data = {
        url: "/api/web/proProject/queryFinalWorkLoad ",
        methods: "post",
        data: params,
        success: succ,
        error: err
      };
      console.log("TCL: getReadOnlyAmapData -> this.$route.params.info", this.$route.params.proId)
      if (params.proId) {
        this.$https(data);
      }

      // mock的模拟数据
      // this.$axios.get("/mock/queryFinalWorkLoad.json").then(res => {
      //   // console.log(res,"axios.get")
      //   succ(res);
      // });
    }
  },
  watch: {},
  components: {
    expansionAmap
  }
};
</script>
<style scoped>
.main {
  width: 1100px;
  margin: 20px auto;
  box-sizing: border-box;
  border: 1px solid #e4e4e4;
  font-size: 14px;
}
.main .nav {
  height: 40px;
  line-height: 40px;
  padding-left: 20px;
  text-align: left;
  background: #f3f3f3;
  color: #666;
  border-bottom: 1px solid #e4e4e4;
  margin-bottom: 30px;
}
.step-container {
  margin-bottom: 60px;
}
.gcl {
  margin-bottom: 20px;
}
.tabs {
  width: 1060px;
  margin: 20px auto;
}
.budget {
  margin-top: 20px;
  width: 100%;
  overflow: hidden;
  background: #f8f8f8;
  height: 35px;
  line-height: 35px;
  font-size: 14px;
  border: 1px solid #e4e4e4;
  border-bottom: none;
  padding: 0 20px;
  box-sizing: border-box;
  font-size: 14px;
  color: #666;
}
.gcl .title {
  background: #f8f8f8;
  height: 35px;
  line-height: 35px;
  color: #666;
  padding: 0 20px;
  font-size: 14px;
  border: 1px solid #e4e4e4;
  border-bottom: none;
  text-align: left;
}
.budget .title {
  float: left;
}
.budget div:last-of-type {
  float: right;
}
.gcl .tabs {
  width: 1060px;
  margin: 20px;
  box-sizing: border-box;
}
.nav {
  background: #f8f8f8;
  height: 50px;
  font-size: 14px;
  line-height: 50px;
  border-bottom: 1px solid #e4e4e4;
  text-align: left;
  padding-left: 20px;
  font-size: 14px;
  color: #666;
}
.tables table {
  width: 660px;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 12px;
}
.budgetTable table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 12px;
}
.budgetTable table td {
  /* width: 500px; */
  height: 40px;
}
.tables table td {
  height: 44px;
}
.tables table td:nth-of-type(2n) {
  text-align: left;
  padding-left: 20px;
}
.tables table td:nth-of-type(2n + 1) {
  text-align: right;
  padding-right: 20px;
  width: 160px;
  background: #f9fafc;
}
.costManage {
  overflow: hidden;
  font-size: 14px;
}
.costManage .left,
.costManage .right {
  float: left;
}
.costManage .left {
  margin-right: 60px;
}
.costManage .cost {
  text-align: left;
  color: #949494;
  margin-bottom: 10px;
}
.costManage .left span,
.costManage .right span {
  display: inline-block;
  width: 100px;
  text-align: right;
  padding-right: 10px;
  height: 30px;
  color: #666;
  font-size: 12px;
}
.costManage .left span i,
.costManage .right span i {
  color: red;
  vertical-align: middle;
  font-style: normal;
  padding-right: 2px;
}
.costManage .left input,
.costManage .right input {
  height: 30px;
  padding-left: 5px;
  outline: none;
  border: 1px solid #e4e4e4;
  border-radius: 2px;
}

/* 下面是进度管理的样式 */
.step-container {
  margin: 20px auto;
}
.table-title p {
  font-family: "PingFangSC-Regular", "PingFang SC";
  font-weight: 400;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  font-kerning: normal;
  font-size: 16px;
  color: #666;
  text-align: left;
  line-height: 40px;
}

.tables table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 12px;
}
.tables table td {
  height: 44px;
}
.tables table td:nth-of-type(2n) {
  text-align: left;
  padding-left: 20px;
  width: 332px;
}
.pipe-progress .tables table td:nth-of-type(2n),
.line-progress .tables table td:nth-of-type(2n),
.equipment-progress .tables table td:nth-of-type(2n) {
  width: 332px;
}
.tables table td:nth-of-type(2n + 1) {
  text-align: right;
  padding-right: 20px;
  width: 160px;
  background: #f9fafc;
}

.component-paging .table-bottom,
.component-paging .table-bottom,
.component-paging .table-bottom {
  width: 100%;
  margin-bottom: 20px;
}

.pipe-progress .table,
.line-progress .table,
.equipment-progress .table {
  margin-top: 20px;
}

/* 材料管理 */
.material-manage .search-header {
  width: 1028px;
  box-sizing: border-box;
  background-color: rgba(255, 255, 255, 1);
  margin: 20px auto 0;
}

.material-manage .search-header .left-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-color: rgba(243, 243, 243, 1);
  height: 45px;
  box-sizing: border-box;
  border: 1px solid rgba(228, 228, 228, 1);
  border-bottom: 0;
}

.material-manage .search-header .left-title .left-text {
  width: 20%;
  color: #666;
  font-size: 14px;
  line-height: 45px;
  font-weight: 700;
  text-align: left;
  margin: 0 0 0 30px;
}

.material-manage .right {
  width: 70%;
  display: flex;
  justify-content: flex-end;
  margin-right: 30px;
}

.material-manage .right button {
  padding: 0 15px;
  height: 30px;
  margin: 6px 5px;
  line-height: 30px;
  font-size: 14px;
  color: #666;
  background-color: #fff;
  border: 1px solid #ccc;
}

.material-manage .right button:hover {
  background-color: #f3f3f3;
}

/* 资料归档 */
.data-back-sign,
.owner-data,
.design-check-data,
.process-manage-data,
.project-finish-data,
.official-data,
.move-system-data {
  margin: 20px auto;
}
.table-title-left {
  color: #1abc9c;
  font-size: 16px;
  float: right;
}

.gray {
  color: #ccc;
}

/* 删除按钮 */
.red {
  color: #48c9b0;
  font-size: 12px;
}

.data-back-sign .tables table td:nth-of-type(2n + 1) {
  text-align: right;
  padding-right: 20px;
  width: 110px;
  background: #f9fafc;
}

.move-system-msg .tables table td:nth-of-type(2n + 1) {
  text-align: right;
  padding-right: 20px;
  width: 140px;
  background: #f9fafc;
}

.table-title > div:last-of-type {
  float: right;
  margin: -45px 20px 10px;
}
.table-title > div:last-of-type span {
  display: inline-block;
  margin-left: 20px;
  padding: 5px 20px;
  margin-top: 10px;
  cursor: pointer;
  border-radius: 4px;
}
.table-title > div:last-of-type span:first-of-type {
  border: 1px solid #e4e4e4;
  color: #666;
  background: #fff;
}
.table-title > div:last-of-type span:last-of-type {
  border: 1px solid #1abc9c;
  color: #fff;
  background: #1abc9c;
}

/* 工程量管理 按钮组 */
.btn_group {
  text-align: left;
  margin-bottom: 15px;
}

/* 工程量管理 底部 价格显示 */
.gcl_footer {
  text-align: right;
}

.gcl_footer .gcl_footer_top {
  margin-bottom: 10px;
  font-size: 18px;
}

.gcl_footer .gcl_footer_top span:nth-child(2n),
.gcl_footer .gcl_footer_bottom span:nth-child(2n) {
  color: #1abc9c;
}

.gcl_footer .gcl_footer_bottom {
  margin-bottom: 10px;
  font-size: 19px;
}

.budgetTable table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 12px;
}
.budgetTable table td,
th {
  height: 40px;
}

th {
  background-color: #f9fafc;
}

/* 建项审批列表最外层容器 expansion-amap Start*/
.expansion-amap {
  widows: 100%;
}
/* 建项审批列表最外层容器 expansion-amap End and 地图容器 Start */
.amap {
  width: 100%;
  height: 500px;
  position: relative;
}
#container {
  position: absolute;
  width: 100%;
  height: 100%;
}
/* 地图容器 End and 数据展示列表 Start */
.table {
  width: 100%;
}
.table-title {
  text-align: left;
  color: #949494;
  font-size: 16px;
}
.amap-all-table-header {
  display: flex;
  align-items: center;
  margin: 10px 0 20px;
}
.amap-all-table-btn {
  width: 120px;
  height: 30px;
  line-height: 30px;
  cursor: pointer;
  border: 1px solid #e4e4e4;
}
.amap-all-table-btn:not(:first-child) {
  margin-left: 20px;
}
.amap-all-table-btn-active {
  background: #1abc9c;
  color: #fff;
}
.amap-all-table-header-update {
  margin-left: 300px;
}
/* 数据展示列表 End */
</style>

<!-- 在全局中修改地图的css -->
<style>
.expansion-amap .marker-container {
  position: relative;
}
.expansion-amap .marker-container img {
  position: absolute;
}
.expansion-amap .marker-container div:nth-child(2) {
  color: red;
  position: absolute;
  top: -20px;
  left: 0;
}
.expansion-amap .marker-container div:nth-child(3) {
  height: 20px;
  line-height: 20px;
  padding: 3px 6px;
  background: #fff;
  border: 1px solid red;
  position: absolute;
  left: 6px;
  top: 6px;
}
</style>
